<template>
	<view class="container">
		<WarnInfo></WarnInfo>
		<view class="employ_part">
			<view class="left">
				<view class="name">
					{{employInfo.title}}
				</view>
				<view class="distance_address">
					{{employInfo.city}} &nbsp;&nbsp;{{employInfo.address}}
				</view>
				<view class="types">
					<view class="type_item" v-for="(type,i) in employInfo.positionLabel" :key="i">
						{{type}}
					</view>
				</view>
			</view>
			<view class="right">
				<view class="distance_address">
					{{employInfo.title}}
				</view>
				<view class="money">
					{{employInfo.salary}}
				</view>
				
			</view>
		</view>
		<blank></blank>
	     <view class="edit_part">
			 <view class="edit_title">编辑评价</view>
			 <view class="text_edit">
			 	<textarea v-model="form.content" placeholder-style="color:##BBBBBB;font-size:28rpx" placeholder="请输入你的评价..." maxlength="500"/>
			 </view>	 
		</view>
		
		<view style="display: flex;">
			<view class="upload_img" v-if="!form.image[0]" @click="upload()">
				<image  src="../../static/img/photo.png" mode=""></image>
			</view>
			<view v-else v-for="(item,index) in form.image" :key="index" class="upload_img" @click="upload()">
					<image :src="  item" mode=""></image>
			</view>
		</view>
		<HandleBtn btnName="确认发布" @click.native="companyComment()" style="margin-top: 60rpx"></HandleBtn>
		
	</view>
</template>

<script>
	import WarnInfo from "../../components/warnInfo.vue";
	import Blank from "../../components/blank.vue"
	import HandleBtn from "../../components/handleBtn.vue"
	export default {
		components: {
			WarnInfo,
			Blank,
			HandleBtn
		},
		data() {
			return {
				employInfo: {
					name: "高级文书顾问/笔译",
					title: "英语翻译",
					distance: "8.6km",
					address: "锦江春熙路",
					price: "4k-10k元/月",
					types: ["交通补贴", "周末双休", "五险一金"],
					avtar:"../../static/img/avartor.png",
					anthor:"2020-6-30 13:30",
				},
				id:null,
				form:{
					companyId:null,
					content:"",
					image:[]
				}

			}
		},
		onLoad(option) {
			this.id = option.id
			this.form.companyId = option.cid
			this.recruitDetail()
			
		},
		methods: {
			companyComment(){
				this.$utils.requert({url:'companyComment',data:this.form,type:'post'}).then(res=>{
						if(res.code === 1 ){
							this.$utils.showLayer(res.message)
							uni.switchTab({
								url:"/pages/myCenter/myCenter"
							})
						}else{    
							this.$utils.showLayer(res.message)
						}
					})
			},
			//详情获取
			recruitDetail(){
				this.$utils.requert({url:'recruitDetail',data:{recruitId:this.id},type:'post'}).then(res=>{
						if(res.code === 1 ){
							// this.$utils.showLayer(res.message)
							this.employInfo = res.data
							// console.log(this.employInfo)
							
						}else{    
							this.$utils.showLayer(res.message)
						}
					})
			},
			//图片上传
			upload(){
				   uni.chooseImage({
					count: 2,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: res=> {
						const file = res.tempFilePaths[0]
						const  token  = uni.getStorageSync('token')
						uni.uploadFile({
							url: this.$utils.domain+'/api/api/uploadImg', //仅为示例，非真实的接口地址
							filePath: file,
							
							name: 'file',
							header:{
								'accessToken':token
							},
							formData: {
								'type': '2'
							},
							success: (res) => {
								var res = JSON.parse(res.data)
								this.imgsFile = this.form.image.push(res.data.src)
								console.log(this.form.image)
							}
						});
					},
					error : function(e){
					 // console.log(e);		
					}
				  });
			},
		}
	}
</script>
<style>
	page {
		width: 100%;
		background-color: #fff;
	}
</style>

<style scoped>
	.container {
		width: 100%;

	}
	.employ_part{
		padding:40rpx 0;
		margin:0 30rpx;
		display: flex;
		justify-content: space-between;
		position: relative;
		box-sizing: border-box;
	}
	.employ_part .name{
		font-size: 31rpx;
		color:#323232;
	}
	 .distance_address{
		font-size: 24rpx;
		color: #838282;
	}
	.employ_part .types{
		display: flex;
		margin-bottom: 30rpx;
		margin-top: 30rpx;
	}
	.employ_part .types .type_item{
		padding:0 8rpx;
		border:1rpx solid #F6F6F6;
		font-size: 25rpx;
		color: #FB8408;
		margin-right: 16rpx;
	}
	.company_person{
		font-size: 24rpx;
		color: #333333;
		display: flex;
		align-items: center;
	}
	.company_person image{
		width:42rpx;
		height: 42rpx;
		margin-right: 17rpx;
	}
	.right{
	 text-align: right;
	}
	.right .money{
		font-size: 28rpx;
		color:#FB8408;
	}
	.edit_part{
		margin:0 24rpx;
	}
	.edit_title{
		font-size: 32rpx;
		color:#323232;
		margin-top:50rpx;
		margin-bottom:32rpx ;
	}
	.text_edit{
		border: 1rpx solid #f6f6f6;
		border-radius: 7rpx;
	}
	textarea{
		padding:32rpx 24rpx;
		width: 100%;
		background-color: #f5f4f6;
		font-size: 28rpx;
		box-sizing: border-box;
		border-radius: 7rpx;
	}
	.upload_img{
		background-color: #E6E6E6;
		width: 200rpx;
		height: 200rpx;
		text-align: center;
		/* position: absolute;
		top:310rpx;
		left:56rpx; */
		margin-left: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 00rpx;
		z-index: 100;
	}
	.upload_img image{
		width:79rpx;
		height: 76rpx;
		margin-top: 62rpx;
	}

</style>
